package com.wcl.demo.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.wcl.demo.R;
import com.wcl.demo.ui.activity.NoteActivity;

/**
 * Created by dllo on 15/11/27.
 */
public class QuitFragment extends DialogFragment implements View.OnClickListener {
    private TextView fragmnent_quit_cansel,fragment_quit_quitBtn;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view=inflater.inflate(R.layout.fragment_quit,container);
        return view;
    }
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        fragmnent_quit_cansel= (TextView) view.findViewById(R.id.fragmnent_quit_cansel);
        fragment_quit_quitBtn= (TextView) view.findViewById(R.id.fragment_quit_quitBtn);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        fragmnent_quit_cansel.setOnClickListener(this);
        fragment_quit_quitBtn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.fragmnent_quit_cansel:
                DialogFragment df = (DialogFragment) getActivity().getSupportFragmentManager().findFragmentByTag("quitfragment");
                df.dismiss();


                break;
            case R.id.fragment_quit_quitBtn://退出编辑
                Intent intent =new Intent(getActivity(), NoteActivity.class);
                getActivity().startActivity(intent);
                getActivity().finish();
                break;
        }
    }
}
